import random,redis
from ronglian_sms_sdk import SmsSDK

accId = '8a216da882f1f59401835463b6491132'
accToken = 'ad8f510c3adb43cd947fce2e105763e1'
appId = '8a216da882f1f59401835463b7481139'


def send_message(mobile):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'  # 容联云分配的一个测试短信验证码模版
    data=random.randint(100000,999999)
    r = redis.Redis(host='localhost', password='123', port=6379, db=5)
    r.set(mobile, data, ex=1200)
    datas = (data, '5')
    resp = sdk.sendMessage(tid, mobile, datas)
    print(resp)
    return  resp


